package net.apexes.demo.codegen.dslite.qvar;

import net.apexes.demo.codegen.dslite.entity.Template;
import net.apexes.demo.codegen.dslite.qvar.base.QEntityBase;
import net.wafo.dslite.core.info.ForeignKey;
import net.wafo.dslite.core.info.Index;

import net.wafo.dslite.core.dsl.*;

/**
 * QTemplate is a DSLite query type for Template
 * @see Template
 */
public class QTemplate extends QEntityBase<Template> {

    public static final QTemplate $ = new QTemplate("TEMPLATE");

    public final StringColumn name = varchar("NAME", 32).field("name").notNull().build();

    public final StringColumn description = varchar("DESCRIPTION", 128).field("description").build();

    public final StringColumn dependTemplateId = varchar("DEPEND_TEMPLATE_ID", 22).field("dependTemplateId").build();

    public class Indexs {

        public final Index constraintIndexDf = index("CONSTRAINT_INDEX_DF").column(dependTemplateId).build();

        public final Index primaryKeyDf = index("PRIMARY_KEY_DF").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public class ForeignKeys {

        public final ForeignKey constraintDfe = foreignKey(dependTemplateId, "TEMPLATE", "ID");

    }

    public final ForeignKeys fk = new ForeignKeys();

    public QTemplate(String tableName) {
        super(Template.class, tableName);
    }

    @Override
    public Template newEntity() {
        return new Template();
    }

    @Override
    public Object getFieldValue(Template entity, String fieldName) {
        switch (fieldName) {
            case "name":
                return entity.getName();
            case "description":
                return entity.getDescription();
            case "dependTemplateId":
                return entity.getDependTemplateId();
            default:
                return super.getFieldValue(entity, fieldName);
        }
    }

    @Override
    public void setFieldValue(Template entity, String fieldName, Object value) {
        switch (fieldName) {
            case "name":
                entity.setName((java.lang.String) value);
                break;
            case "description":
                entity.setDescription((java.lang.String) value);
                break;
            case "dependTemplateId":
                entity.setDependTemplateId((java.lang.String) value);
                break;
            default:
                super.setFieldValue(entity, fieldName, value);
                break;
        }
    }

}

